package com.beta.cat.service;

import org.redisson.api.RScoredSortedSet;
import org.redisson.api.RSortedSet;
import org.redisson.api.RedissonClient;

import java.time.Duration;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;

public interface RedissonService {

    RedissonClient getRedissonClient();

    void setRedissonClient(RedissonClient redissonClient);

    boolean tryLock(String lockName, long waitTime);

    boolean tryLock(String lockName, long leaseTime, long waitTime);

    void unlock(String lockName);

    boolean isLock(String lockName);

    boolean isHeldByCurrentThread(String lockName);

    String getStr(String key);

    void setStr(String key, String value);

    <T> T get(String key);

    <T> T get(String key, Class<T> t);

    <T> List<T> getList(String key, Class<T> t);

    void set(String key, Object value);

    void set(String key, Object value, long time);

    void setJson(String key, Object value);

    void setJson(String key, Object value, long time);

    void expire(String key, Duration expireTimeDuration);

    long incr(String key);

    long incrBy(String key, long value);

    long decr(String key);

    boolean delete(String key);

    boolean bitSet(String key, long index, boolean value);

    boolean bitGet(String key, long index);

    Integer putSortedSet(String key, Double score, Object value, Duration expireTime);

    Integer putSortedSet(String key, Double score, Object value);

    Integer addScore(String key, Double addScore, Object value, Duration expireTime);

    List<Object> rankRange(String key, Integer top);

    <T> List<T> rankRange(String key, Long minScore, Long maxScore, Integer maxCount, Class<T> t);

    RScoredSortedSet<Object> rankRangeAll(String key);

    Integer getRank(String key, Object value);

    void lPush(String key, String... values);

    boolean zadd(String key, Long score, String userId);

    Integer revrank(String key, String value);

    Collection<String> zrevrange(String key, int start, int end);

    boolean sadd(String key, Object value);

    Integer getSetLenth(String key);

    RSortedSet getSet(String key);

    <T> List<T> getRList(String key, Integer value, Class<T> t);

    boolean addList(String key, Object value);

    boolean isSetExists(String key, String param);

    boolean setAdd(String key, Object value);

    boolean setAddAll(String key, Set<Object> objectSet);

    boolean saddAll(String key, Set<Object> set);

    Integer getZSetSize(String key);

    boolean isSetExistsSync(String key, String param);

    public <T> T getMapValue(String key, Object mapKey, Class<T> t);

    public <K, V> void setMap(String key, Map<K, V> mapParam);

    public boolean isExistMap(String key);
}
